/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.evl.tecinfo.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Jalisson
 */
public class ImagePanel extends JPanel {  
  
    private Image image;  
    
    private String caminhoImagem = "";
  
    public ImagePanel(String imagem) { 
        caminhoImagem = imagem;
        this.initialize();  
    }  
  
    protected void initialize() {  
        this.image = this.getImage(caminhoImagem);  
          
        this.setLayout(new BorderLayout());  
    }  
  
    public Image getImage(String path) {  
 
        return new ImageIcon(path).getImage();  
    }  
  
    public void paintComponent(Graphics g) {  
        super.paintComponent(g);  
        Dimension dDesktop = this.getSize();  
  
        double width = dDesktop.getWidth();  
        double height = dDesktop.getHeight();  
  
        Image background = new ImageIcon(this.image.getScaledInstance(  
                (int) width, (int) height, 1)).getImage();  
  
        g.drawImage(background, 0, 0, this);  
    }  
  
 
}   
    

